﻿Imports DTO
Imports System.Data.SqlClient
Public Class CQuyenHanDAO
    Public Function LayTenQuyenTheoMa(ByVal ma As Integer) As String
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspLayTenQuyenTheoMa", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim para As SqlParameter = New SqlParameter("@Ma", ma)
            cm.Parameters.Add(para)
            Dim str As String = cm.ExecuteScalar()
            cn.Close()
            cn.Dispose()
            cm = Nothing
            Return str
        End Using
    End Function

    Public Function LoadQuyenHan() As List(Of CQuyenHanDTO)
        Using cn As SqlConnection = CDataProvider.Connect()
            Dim cm As New SqlCommand("uspLoadQuyenHan", cn)
            cm.CommandType = CommandType.StoredProcedure
            Dim lquyen As New List(Of CQuyenHanDTO)
            Using reader As SqlDataReader = cm.ExecuteReader(CommandBehavior.CloseConnection)
                While reader.Read()
                    lquyen.Add(New CQuyenHanDTO(reader))
                End While
            End Using
            Return lquyen
        End Using
    End Function

End Class
